use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DataSourceConfig {
    pub source_type: String,
    pub api_endpoint: String,
    pub api_key: Option<String>,
    pub connection_timeout: u64,
    pub max_retries: u32,
    pub retry_delay: u64,
    pub cache_ttl: u64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MultiDataSourceConfig {
    pub primary: DataSourceConfig,
    pub backups: Vec<DataSourceConfig>,
    pub auto_switch: bool,
    pub switch_back_delay: u64,
}

impl Default for DataSourceConfig {
    fn default() -> Self {
        Self {
            source_type: "akshare".to_string(),
            api_endpoint: "".to_string(),
            api_key: None,
            connection_timeout: 30,
            max_retries: 3,
            retry_delay: 1,
            cache_ttl: 300,
        }
    }
}

impl Default for MultiDataSourceConfig {
    fn default() -> Self {
        Self {
            primary: DataSourceConfig::default(),
            backups: vec![],
            auto_switch: true,
            switch_back_delay: 300,
        }
    }
}